import React, { useEffect, useState } from 'react'
import axios from 'axios';

export default function App() {
  const [count, setCount] = useState(0)

  const addHandle = () => {
    setCount(count + 1)
  }

  //刚加载就发送请求
  useEffect(() => {
    axios.get("/api1/login")
  }, [])

  //count改变发送请求
  useEffect(() => {
    axios.get("api1/user")
  }, [count])

  return (
    <div>
      <h1>count{count}</h1>
      <button onClick={addHandle}>累加</button>
    </div>
  )
}
